<?php 
	$config 		= new Zendvn_Controller_Config(array('module'=>'admin',
											'fileConfig'=>'product-category.ini'));
	$itemConfig 	= $config->getconfig('item');
	
	$filter 		= new Zendvn_Filter_Filter();
	
	$categoryName 	= Zendvn_Filter_Filter::filterContent($this->categoryInfo['name'], 'filter');
	$this->headTitle = empty($this->headTitle)?$categoryName:$this->headTitle;
	
	$arrDayWeek		= array('1' => 'Thứ hai', '2' => 'Thứ ba', '3' => 'Thứ tư', '4' => 'Thứ năm', '5' => 'Thứ sáu',
							'6' => 'Thứ bảy', '7' => 'Chủ nhật');
?>
	<div class="box-header">
      	<h3><?php echo $this->headTitle?></h3>
  	</div>
 	<?php 
 	if(!empty($this->Items)):
 		echo '<div class="product_category">';
 		$i = 0;
 		foreach ($this->Items as $k => $v):
 			$i++;
 			$stylePrice = '';	
	 		$id			= $v['id'];
	 		$cat_id		= $v['cat_id'];
	 		$name 		= Zendvn_Filter_Filter::filterContent($v['name'], 'filter');
	 		$price 		= $v['price'];
	 		$sell_off	= $v['sale_price'];
	 		
	 		$newPrice 	= (empty($sell_off) || $sell_off == 0)?$price:$sell_off;
	 		$textPrice 	= (empty($sell_off) || $sell_off == 0)?'Giá':'Giá khuyến mãi';
	 		
	 		$lastProduct = ($i%3 == 0)?' last':'';
	 		
	 		$content	= Zendvn_Filter_Filter::filterContent($v['content']);
	 		$content	= Zendvn_Filter_Filter::shortString(strip_tags($content), 400);
	 		
	 		$created	= $v['created'];
	 		$dayWeek	= date('N', strtotime($created));
	 		$created	= $arrDayWeek[$dayWeek] . ', ' . date('d/m/Y', strtotime($created));
	 		
	 		$picture 	= $v['image'];
	 		if(file_exists($itemConfig['uploadDir'] . '/' . $picture) && !empty($picture)){
	 			$picture = $itemConfig['uploadUrl'] . '/' . $picture;
	 		}else{
	 			$picture = FILE_URL . '/no-image.png';
	 		}
	 			
	 		
	 		if($this->arrParam['action'] == 'product-category'){
//	 			$cat_id = $this->arrParam['id'];
	 		}
	 		$linkProduct = $this->cmsUrl(array(
	 				'module' => 'default',
	 				'controller' => 'index',
	 				'action' => 'product-detail',
					'cat_id'=> $cat_id,
	 				'id' => $id,
	 				'title' => $filter->filter($name)
	 		), 'product-detail');
	 		$linkOrder = $this->cmsUrl(array(
									'module' => 'default',
									'controller' => 'index',
									'action' => 'order',
									'product_id' => $id
									));
 		
 	?>
    	<div class="lev<?php echo $lastProduct?>">
         	<div class="product_name">
          		<a href="<?php echo $linkProduct?>"><?php echo $name?></a>
         	</div>
       		<div class="product_img">
          		<a href="<?php echo $linkProduct?>"><img src="<?php echo $picture?>" alt="maxx99" title="<?php echo $name?>" /></a>
        	</div>	
         	<div class="product_info">
             	<div class="price">
             		<?php if(!empty($sell_off) || $sell_off != 0): ?>
                 	<span class="normal-price"><?php echo number_format($price)?></span>
                 	<?php else: $stylePrice = ' style="margin-top: 25px;"'; endif;?> 
                 	<span class="special-price"<?php echo $stylePrice?>><?php echo number_format($newPrice)?></span>
             	</div>
            	<div class="button">
	              	<a  href="<?php echo $linkOrder?>" onclick="return fancyBox(this)">Đặt hàng</a>
             	</div>
        	</div>
        	<?php if(!empty($sell_off) || $sell_off != 0):?>     
        	<span class="sale_icon"></span>	
        	<?php endif;?>
      	</div>
    <?php 
    endforeach;
    	echo '<div class="clr"></div>';
		$arrParam = array(
						'module' => 'default',
						'controller' => 'index',
						'action' => $this->arrParam['action'],
						'id' => $this->arrParam['id'],
						'title' => $this->arrParam['title']
						);
		if($this->arrParam['action'] == 'product-category'){
			$arrParam['router'] = 'product-category-page';
		}elseif($this->arrParam['action'] == 'new-product'){
			$arrParam['router'] = 'new-product-page';
		}elseif($this->arrParam['action'] == 'special-product'){
			$arrParam['router'] = 'special-product-page';
		}elseif($this->arrParam['action'] == 'all-product'){
			$arrParam['router'] = 'all-product-page';
		}			
		echo $this->paginationControl($this->panigator,'Sliding','paning.php',array('arrParam'=>$arrParam)); 
		echo '</div>';
 	else:
 		echo '<div class="warning_empty">Sản phẩm danh mục này đang được chúng tôi cập nhật...</div>';
 	endif;
	?>
             	
